/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ZhongJinTao
 * Date: 2024-02-02
 * Time: 21:45
 */
public class ThreadDemo1 {
    private static int sum = 0;
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(new Runnable() {
            int result = 0;
            @Override
            public void run() {
                for (int i = 1; i <= 1000; i++) {
                    result += i;
                }
                sum = result;
            }
        });
        t.start();
        t.join();
        System.out.println("sum = " + sum);
    }
}
